package com.qqtech.qquan.mall.enums;


public enum MallSortTypeEnum {
	/**
	 * 排序类型:sales-销量;distance-距离
	 */
	SALES("sales", "销量"),
	DISTANCE("distance", "距离");
    String code;
    String desc;

    MallSortTypeEnum (String code, String desc) {
        this.code = code;
		this.desc = desc;
	}

	public String getCode() {
		return code;
	}
	public String getDesc() {
		return desc;
	}
	
	public static String getDesc(String code) {
		if(code!=null){
			for (MallSortTypeEnum e : MallSortTypeEnum.values()) {
				if (code.equals(e.getCode())) {
					return e.desc;
				}
			}
		}		
		return "";
	}
    
    public static boolean isInScope(String code) {
		if (code == null) {
			return false;
		}
		MallSortTypeEnum[] arrEnum = MallSortTypeEnum.values();
		for (MallSortTypeEnum e : arrEnum) {
			if (e.code.equalsIgnoreCase(code)) {
				return true;
			}
		}
		return false;
	}
}

